<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <!-- import CSS -->
    <link rel="stylesheetL" href="https://cdn.staticfile.org/element-ui/2.15.9/theme-chalk/index.css">
    <style>
        body{
            margin: 0;
            background-color: #F6F1EBFF;
            background-size: cover;
            background-repeat: no-repeat;
            background-attachment: fixed;


        }
        .el-header {
            height: 20px;
        }
        .el-header img{
            vertical-align: middle;/*中间对齐*/
        }
        .el-header a{
            color:black;
            text-decoration: none;
        }
        .el-table .el-table__cell{
            padding: 0;/*去掉自带的内边距*/
        }
        .el-table .cell{
            /*设置一行显示, 超出部分显示省略号*/
            white-space: nowrap;
        }
    </style>
</head>
<body>

<div id="app">
    <el-container>
        <el-header height="150px"  class="el-header">
            <div class="d1" style="width: 100%; background-color: #F6F1EBFF ;top: 10px">

                   <ul class="u1">
                       <li class="x1">
                           <h3>目录</h3>
                       </li>
                       <li class="x2">
                           <el-input type="text" v-model="wd" placeholder="搜索"></el-input>
                       </li>
                       <li class="x3">
                           <img src="../src/assets/logo.png" width="100px" >
                       </li>
                       <li class="x4">
                              <h4>账户   购物袋</h4>
                       </li>
                   </ul>


                </div>
                    <div align="right"> <a href="">店铺地址   联系我们</a><el-divider direction="vertical"></el-divider>


            </div>

            <div style="background-color:  #F6F1EBFF">
                <el-menu style="width: 1200px;margin: 0 auto" mode="horizontal"
                         background-color="#F6F1EBFF" text-color="black"
                         active-text-color="black" @select="handleSelect">
                    <el-menu-item v-for="c in categoryArr"
                                  :index="c.id">{{c.name}}</el-menu-item>
                </el-menu>
            </div>
        </el-header>
        <el-main style="width: 1200px;margin: 0 auto;background-color: #F6F1EBFF ">
            <el-row gutter="20">
                <el-col span="18">
                    <!--走马灯开始-->
                    <el-carousel height="300px">
                        <el-carousel-item v-for="b in bannerArr">
                            <img :src="b.url" width="100%" height="100%">
                        </el-carousel-item>

                    </el-carousel>
                    <!--走马灯结束-->
                </el-col>
                <el-col span="6">
                    <el-card>
                        <h3>
                            <i style="font-weight: bold"
                               class="el-icon-trophy">狗</i>
                        </h3>
                        <el-divider></el-divider>
                        <el-table :data="topArr">
                            <!--type="index" 设置当前列的内容为12345678-->
                            <el-table-column type="index" label="狗"></el-table-column>
                            <el-table-column prop="title" label="猫"></el-table-column>
                            <el-table-column prop="saleCount" label="收养量"></el-table-column>
                        </el-table>
                    </el-card>

                </el-col>
            </el-row>
            <!--商品列表开始-->
            <el-row gutter="20">
                <el-col style="margin: 10px 0" span="6" v-for="p in productArr">
                    <el-card>
                        <a :href="'/detail.html?id='+p.id">
                            <img :src="p.url" width="100%">
                        </a>

                        <p style="font-size: 14px">
                            <a :href="'/detail.html?id='+p.id">
                                {{p.title}}
                            </a>
                        </p>
                        <p style="font-size: 12px">￥{{p.price}} <s>{{p.oldPrice}}</s>
                            <span style="float: right">销量:{{p.saleCount}}件</span>
                        </p>
                    </el-card>
                </el-col>
            </el-row>
            <!--商品列表结束-->
        </el-main>
        <el-footer>
            <div style="background-image: url('../../src/assets/images/wave.png');height: 95px">
            </div>
            <div style="text-align: center;background-color:white;
            color: #b1b1b1;padding: 30px 0">
                <p> 需要帮助吗？</p>
                <p>  您或许可以在常见问题中找到答案。</p>
                <p> 也可以联系我们：</p>

                <p>  客服中心 400 090 6610</p>
                <p>   周一至周日: 10点 - 22点 </p>
                <p>查询附近的宠物店</p>

            </div>
        </el-footer>
    </el-container>
</div>

</body>


    <!--引入axios和vue框架-->
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<!-- import Vue before Element -->
<script src="https://cdn.staticfile.org/vue/2.6.14/vue.min.js"></script>
<!-- import JavaScript -->
<script src="https://cdn.staticfile.org/element-ui/2.15.9/index.min.js"></script>
<script>
    let v = new Vue({
        el: '#app',
        data: function () {
            return {
                categoryArr:[],
                bannerArr:[],
                topArr:[],
                productArr:[],
                wd:""
            }
        },
        methods:{
            handleSelect(key,keyPath){
                console.log(key);
                //key是导航菜单中的index,而index的值设置的是分类的id
                //跳转到显示结果的页面 把分类的id传递过去
                location.href="/result.html?id="+key;
            },
            search(){
                if (v.wd.trim()==""){
                    v.$message.error("请输入搜索的内容!");
                    return;
                }
                //和点击分类显示结果一样 复用同一个页面
                location.href="/result.html?wd="+v.wd;
            }
        },
        created:function () {
            //发请求获取所有分类信息
            axios.get("/category/select").then(function (response) {
                v.categoryArr = response.data;
            })
            //发请求获取所有轮播图信息
            axios.get("/banner/select").then(function (response) {
                v.bannerArr = response.data;
            })
            //发请求获取排行榜数据
            axios.get("/product/selectTop").then(function (response) {
                v.topArr = response.data;
            })
            //发请求获取所有商品数据
            axios.get("/product/selectIndex").then(function (response) {
                v.productArr = response.data;
            })
        }
    })
</script>
    <style>
        .d1{
            padding: 10px 25px ;
        }
        .u1{padding: 0;
        margin: 0;}
        li{
            display: inline-block;
            padding: 4px 10px;

        }
        .x1{
            margin-left: 100px;
        }
        .x2{
            margin-left: 25px;
        }
        .x3{
           margin-left: 500px;

        }
        .x4{
         float: right;
        }
    </style>
</html>
